package com.zhai.domain.strategy.service.rule.tree.factory;

import com.zhai.domain.strategy.model.valobj.RuleLogicCheckTypeVO;
import com.zhai.domain.strategy.model.valobj.RuleTreeVO;
import com.zhai.domain.strategy.service.rule.tree.ILogicTreeNode;
import com.zhai.domain.strategy.service.rule.tree.factory.engine.impl.DecisionTreeEngine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Description: 默认规则树工厂
 * @ClassName: DefaultTreeFactory
 * @Author: zhaiyongxin
 * @Date: 2025/2/5 15:03
 * @Version: 1.0
 */
@Service
public class DefaultTreeFactory {


    private final Map<String, ILogicTreeNode> logicTreeNodeGroup;

    /**
     * 汇总所有节点集合
     * @param logicTreeNodeGroup
     */
    public DefaultTreeFactory(Map<String, ILogicTreeNode> logicTreeNodeGroup) {
        this.logicTreeNodeGroup = logicTreeNodeGroup;
    }

    public DecisionTreeEngine openLogicTree(RuleTreeVO ruleTreeVO) {
        return new DecisionTreeEngine(logicTreeNodeGroup, ruleTreeVO);
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    public static class TreeActionEntity {
        private RuleLogicCheckTypeVO ruleLogicCheckType;
        private StrategyAwardVO strategyAwardVO;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    public static class StrategyAwardVO {
        /**
         * 奖品id
         */
        private Integer awardId;
        /**
         * 奖品规则 该奖品对应的获取规则是什么
         */
        private String awardRuleValue;
    }
}
